package com.zjb.wxlisener.until;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import java.util.Date;
import java.util.HashMap;


public class JWTUntil {
    private static String username = "zjbbobo";
    private static Long expire = 43200000L;

    public static String getJWT(HashMap<String, Object> claims){
        String jwt = Jwts.builder()
                .addClaims(claims)
                .signWith(SignatureAlgorithm.HS256,username)
                .setExpiration(new Date(System.currentTimeMillis() + expire))
                .compact();
        System.out.println(jwt);
        return jwt;
    }
    public static Claims konwJWT(String jwt){
        Claims claims = Jwts.parser()
                .setSigningKey(username)
                .parseClaimsJws(jwt)
                .getBody();
        return claims;
    }
}
